#include "stdafx.h"

#include "SharpSDL.h"
#include "Audio.h"

void SharpSDL::ManagedSDL::Audio::AudioDriverInit(char* DriverName)
{
	if (SDL_AudioInit((const char*)DriverName) < 0)
		SharpSDL::SDL::Error::SetError(SharpSDL::SDL::Error::ErrorCode::AUDIO);
}

void SharpSDL::ManagedSDL::Audio::AudioQuit(void)
{
	SDL_AudioQuit();
}

System::String ^SharpSDL::ManagedSDL::Audio::GetAudioDriverName(char* DriverName, int MaxLength)
{
	System::String ^s = gcnew String( SDL_AudioDriverName(DriverName, MaxLength));
	return s;
}

SharpSDL::ManagedSDL::Audio::AudioStatus SharpSDL::ManagedSDL::Audio::GetAudioStatus(void)
{
	switch (SDL_GetAudioStatus())
	{
	case 0:
		return SharpSDL::ManagedSDL::Audio::AudioStatus::Stopped;
		break;
	case 1:
		return SharpSDL::ManagedSDL::Audio::AudioStatus::Playing;
		break;
	case 2:
		return SharpSDL::ManagedSDL::Audio::AudioStatus::Paused;
		break;
	default:
		SharpSDL::SDL::Error::SetError(SharpSDL::SDL::Error::ErrorCode::AUDIO);
		return SharpSDL::ManagedSDL::Audio::AudioStatus::Paused;
		break;
	}
}

void SharpSDL::ManagedSDL::Audio::LockAudio(void)
{
	SDL_LockAudio();
}

void SharpSDL::ManagedSDL::Audio::UnlockAudio(void)
{
	SDL_UnlockAudio();
}

void SharpSDL::ManagedSDL::Audio::CloseAudio(void)
{
	SDL_CloseAudio();
}